package com.fileDemo;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: FENGYiMing
 * @Date: 2024/04/10/15:38
 * @Description:
 */
public class Properties01 {
    public static void main(String[] args) throws IOException {
        //普通方法读取：
        //BufferedReader br = new BufferedReader(new FileReader("src/mySql.properties"));
        //String s;
        //while ((s = br.readLine()) != null) {
        //    System.out.println(s);
        //}
        //读取配置文件
        //    Properties properties = new Properties();
        //    properties.load(new FileReader("src/mySql.properties"));
        //    properties.list(System.out);
        //    String ip = properties.getProperty("ip", "feng");
        //    String name = properties.getProperty("name");
        //    System.out.println(name);
        //    System.out.println(ip);
        Properties properties1 = new Properties();
        properties1.setProperty("name", "山河");
        properties1.setProperty("age", "12");
        properties1.store(Files.newOutputStream(Paths.get("src/person.properties")), "备注");
    }
}
